{ 
Function:     _AvgDollarsTraded        (Millions) 

Description:  Calculates the average dollars being traded in the interval selected.
              Automatically adjusts for nuances in coding to obtain correct total volume
              on charts.

              For Day, Weekly or Monthly charts, displays Average Dollars Traded in Millions.
              For tick and intraday charts, displays Average Dollars Traded in Thousands.
     
              Although the use of Ticks is unncessary in Radarscreen, since Volume works
              correctly in all time frames, this function may be called from either 
              charts or Radarscreen, and the correct result will be obtained.
     
Author:       MarkSanDiego

Updated:      01/06/07    oiginal version
              03/04/08    average adjusted to average price*Volume of Length bars.
                          Previously was = Current Price * Average Volume.
              03/06/08    simply single function that works correctly when called
                          from either Charts or Radarscreen.
              01/30/11    Version 9.0 update

}

Inputs:
   Price(NumericSeries),
   Length(NumericSimple);

vars:
   Amount(0),
   AvgDollarsTraded(0),
   InitMargin(0),
   IntradayMargin(0),
   MaintMargin(0);


   if _Future then Amount = _Margin(InitMargin, IntradayMargin, MaintMargin)
       else Amount = Price;
 
   if BarType >= 2 then             //day, weekly or monthly}
       AvgDollarsTraded = (Amount / 1000000) * Volume
   else              //tick or minute}
       AvgDollarsTraded = (Amount / 1000) * Ticks;

 
   _AvgDollarsTraded = AverageFC(AvgDollarsTraded, Length);